/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2023/4/11
 */

import type { App } from '@vue/runtime-core'
import * as ElementPlusIcons from '@element-plus/icons-vue'

const iconResults: string[] = []
export const getElementIcons = async () => {
    if (iconResults.length === 0) {
        try {
            for (const key in ElementPlusIcons) {
                iconResults.push('pt-' + key)
            }
        } catch (e) {
            console.error('导入【@element-plus/icons-vue】失败')
        }
    }

    return iconResults
}

/**
 * 全局注册icon组件
 * @param app
 */
export const regElementIcon = (app: App) => {
    try {
        for (const key in ElementPlusIcons as any) {
            app.component(key, (ElementPlusIcons as any)[key])
        }
    } catch (e) {
        console.error('导入【@element-plus/icons-vue】失败')
    }
}
